package cn.guxinhu.billsystem;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author Guxinhu
 * @create 2021-06-15 0:03
 */

@Configuration
public class MyWebAppConfigurer
        extends WebMvcConfigurerAdapter {

    //注意!!!配置磁盘路径在启动时必须创建文件夹,如D盘下必须有imag文件夹下.否则启动会报错.
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /*addResourceHandler("/imag/**")指定访问路径,
         *比如系统访问地址为localhost:8088,那我们请求路径为localhost:8088/imag/test.img
         *addResourceLocations("file:D:/imag/")指定本地磁盘路径(可设置挂载磁盘或局域网共享磁盘)
         *本次示例中D:/imag/test.img
         */
        registry.addResourceHandler("/bill/**").addResourceLocations("file:X:/bill/");
        super.addResourceHandlers(registry);
    }

}